import request from '@/utils/request';
import type {
	HospitalDetailResponse,
	DeparmentResponseData,
	UserCodeResponseData,
	LoginData,
	LoginResponseData,
	WXLoginResponseData,
	HospitalWorkResponseData,
	HospitalDoctorResponseData,
	PatientInfoResponseData,
	DoctorInfoResponseData,
} from './type';

enum API {
	// 医院详情
	HOSPITALDETAIL = '/hosp/hospital/',
	// 获取某个医院科室数据
	HOSPITALDEPARMENT = '/hosp/hospital/department/',
	// 获取验证码
	USERCODE = '/sms/send/',
	// 用户登录
	LOGIN = '/user/login/',
	// 获取微信登录参数
	WX_LOGIN = '/user/weixin/getLoginParam/',
	// 获取某一个医院的某一个科室预约挂号数据
	HOSPITALWORK = '/hosp/hospital/auth/getBookingScheduleRule/',
	// 获取医院某一个科室某一天相应医生排班的数据
	HOSPITALDOCTOR = '/hosp/hospital/auth/findScheduleList/',
	// 获取某一个账号下就诊人的信息
	PATIENT_INFO = '/user/patient/auth/findAll',
	// 获取挂号医生的信息
	DOCTOR_INFO = '/hosp/hospital/getSchedule/',
}

// 获取医院详情
export function getHospitalDetail(hoscode: string) {
	return request.get<any, HospitalDetailResponse>(API.HOSPITALDETAIL + hoscode);
}

// 获取某个医院科室数据
export function getHospitalDeparment(hoscode: string) {
	return request.get<any, DeparmentResponseData>(API.HOSPITALDEPARMENT + hoscode);
}

// 获取验证码
export function getUserCode(phone: string) {
	return request.get<any, UserCodeResponseData>(API.USERCODE + phone);
}

// 登录
export function login(data: LoginData) {
	return request.post<any, LoginResponseData>(API.LOGIN, data);
}

// 获取微信登录参数
export function getWxLoginParam(wxRedirectUri: string) {
	return request.get<any, WXLoginResponseData>(API.WX_LOGIN + '?wxRedirectUri=' + wxRedirectUri);
}

// 获取某一个医院的某一个科室预约挂号数据
export function getHospitalWork(page: number, limit: number, hoscode: string, depcode: string) {
	return request.get<any, HospitalWorkResponseData>(API.HOSPITALWORK + `${page}/${limit}/${hoscode}/${depcode}`);
}

// 获取医院某一个科室某一天相应医生排班的数据
export function getHospitalDoctor(hoscode: string, depcode: string, workDate: string) {
	return request.get<any, HospitalDoctorResponseData>(API.HOSPITALDOCTOR + `${hoscode}/${depcode}/${workDate}`);
}

// 获取某一个账号下就诊人的信息
export function getPatientInfo() {
	return request.get<any, PatientInfoResponseData>(API.PATIENT_INFO);
}

// 获取挂号医生的信息
export function getDoctorInfo(scheduleId: string) {
	return request.get<any, DoctorInfoResponseData>(API.DOCTOR_INFO + scheduleId);
}
